package com.example.thymeleafrbac.web.exception;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


@ControllerAdvice
public class GlobalExceptionHandler {

  public static final String DEFAULT_ERROR_VIEW = "view/error/404"; // 错误显示页error.html

    /**
     * 出现异常会执行此方法
     * @param e
     * @param model
     * @return
     */
    @ExceptionHandler
    public String handler(Exception e, Model model){
        model.addAttribute("err",e.getMessage());
        return "view/error/404.html";
    }
}
